import java.util.Scanner;

public class HJ85 {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            String str = sc.nextLine();
            StringBuilder sb = new StringBuilder();
            sb.append(str);
            sb.reverse();
            int max = 0;
            for(int i = 0 ;i < str.length(); i++){
                for(int j = i + 1; j < str.length(); j++){
                    if(str.contains(sb.substring(i,j))){
                        if(j - i > max){
                            max = j - i;
                        }
                    }
                }
            }

            System.out.println(max);
        }
    }

}
